//
//  XDTools.h
//  HengHuaSupervision
//
//  Created by XD-XY on 3/20/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "XDNavigationController.h"
#import "AppDelegate.h"
#import "JSONKit.h"

#import "UILabel+Category.h"
#import "UIView+Category.h"
#import "UIButton+Category.h"
#import "UserInfo.h"
#import "FMDB.h"
#import "MBProgressHUD.h"

@class FMDatabase,MainViewController,ImageWallViewController;

@interface XDTools : NSObject

DEFINE_SINGLETON_FOR_HEADER(XDTools)

@property (nonatomic,assign)BOOL isReflash;
@property (nonatomic,strong)MainViewController * mvc;
@property (nonatomic,strong)ImageWallViewController * ivc;
@property (nonatomic,strong)NSString * waitCumitCount; //待提交多少个
@property (nonatomic,strong)NSString * ud; //用户首次安装，并首次登录时的账号
@property (nonatomic,assign)BOOL isupClick;             //一键提交是否点击

//获取导航栏控制器的指针
+(XDNavigationController * )getAppNavigationControllerPointer:(UINavigationController *)navigationController;

//判断有无网络
+(BOOL)NetworkReachable;

//json解析
+ (NSDictionary *)JSonFromString:(NSString* )result;

//无损伤拉伸图片
+(UIImage *)stretchableImag:(UIImage *)image;

+ (AppDelegate *)appDelegate;

//Label自适应大小
+(CGRect )xyAutoSizeOfWidget:(UILabel *)widget andSize:(CGSize)size andtextFont:(CGFloat )sizefont;

//获取uuid
-(NSString *)gen_uuid;

//将数据库文件复制到沙盒目录
+(void)moveToDBFile;

//获得沙盒数据库文件的路径
+(NSString *)databaseFilePath;

+ (BOOL)isValidCoordinate:(CLLocationCoordinate2D)coordinate;

//打开数据
+(FMDatabase*)getDb;

//获取文件大小
-(long long) fileSizeAtPath:(NSString*) filePath;

//写入keychain
+(void)savePassWord:(NSString *)password;
//在keychain中读取udid
+(id)readPassWord;
//删除udid
+(void)deletePassWord;

//MBProgress
+ (void)showProgress:(UIView *) view;
+ (void)showProgress:(UIView *) view showText:(NSString*)text;
+ (void) showTips:(NSString *)text toView:(UIView *)view;
+ (void)showSuccessTips:(NSString *)text toView:(UIView *)view;
+ (void)showErrorTips:(NSString *)text toView:(UIView *)view;
+ (void)hideProgress:(UIView *)view;

+(UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize image:(UIImage *)image;

//判断当前时间和过去时间的时间差
- (NSString *)intervalSinceNow:(NSString *) theDate;

@end
